/**
 * 
 */
package com.starhub.sample.webapp.controllers.personal.mobile;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.starhub.sample.entities.Banner;
import com.starhub.sample.entities.Tab;
import com.starhub.sample.services.BannerService;
import com.starhub.sample.services.TabService;
import com.starhub.sample.services.TabTileService;

/**
 * @author Hoan.NguyenTrong Jan 7, 2015
 * 
 */
@Controller
@RequestMapping(value = "/personal")
public class MobileController {

    private static final Log LOG = LogFactory.getLog(MobileController.class);

    @Autowired
    private BannerService bannerService;
    @Autowired
    private TabService tabService;
    @Autowired
    private TabTileService tabTileService;

    /**
     * To load personal/mobile page
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/mobile")
    public ModelAndView loadHomePage(final HttpServletRequest request) {

	if (LOG.isDebugEnabled()) {
	    LOG.debug("::" + "Loading personal/mobile page");
	}

	final ModelAndView mav = new ModelAndView("personal.mobile.page");

	List<Banner> bannerList = bannerService.getAllBanners();
	mav.addObject("bannerList", bannerList);

	List<Tab> tabList = tabService.getAllTabs();
	mav.addObject("tabList", tabList);
	
	return mav;
    }
}
